package com.ictravi.iamunit;

import java.util.Collection;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.ddsteps.step.TestStep;
import com.ictravi.iamunit.IAMUnitException;
import com.ictravi.iamunit.connector.Connector;

/**
 * Main class for executing a test case
 * 
 * @author Albert Louw (alouw@ictavi.com)
 * @version v1.0.0
 * @since v1.0.0
 **/
public class TestStepExecute implements TestStep {
	static Log LOG = LogFactory.getLog(IAMUnitTestCase.class);
	private Connector connector;
	private Map<String, Collection<String>> data;
	@SuppressWarnings("rawtypes")
	private Map operationData;
	private String operation;

	/**
	 * Instantiate and initialize the transaction object
	 * @param operationalDataMap
	 * 			operationaldatamap for this line
	 * @param iamUnitConnector
	 * 			the connector to run the test on
	 * @param operation
	 * 			current value of the operation
	 * @param data
	 * 			the attributemap to operate on
	 * @since v1.0.0
	 */
	public TestStepExecute(
			@SuppressWarnings("rawtypes") Map operationalDataMap,
			Connector iamUnitConnector, String operation,
			Map<String, Collection<String>> data) {
		LOG.debug("...in: testStepExecute");
		this.connector = iamUnitConnector;
		this.operation = operation;
		this.data = data;
		this.operationData = operationalDataMap;
	}

	/**
	 * Execute the test step.
	 * @since v1.0.0
	 */
	public void runStep() throws IAMUnitException {
		LOG.debug("...in: runStep, about to execute: "
				+ operationData.get("operation"));
		connector.execute(operation, data);
	}
}
